package org.jeecg.modules.finance.mapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.manage.entity.CaishuiBusinessBank;
import org.jeecg.modules.manage.entity.CaishuiRecharge;

import java.util.List;
import java.util.Map;

/**
 * @Description: 账户充值
 * @Author: yfkj
 * @Date:   2023-02-22
 * @Version: V1.0
 */
@InterceptorIgnore(tenantLine = "true")
public interface CaishuiRechargeMapper extends BaseMapper<CaishuiRecharge> {

    /**
     * 查询充值总额
     * @param params
     * @return
     */
    public Map<String,Object> queryTotalAmount(@Param("params") Map<String, String> params);

    /**
     * 查询最新充值的8条记录
     * @param params
     * @return
     */
    public List<Map<String,Object>> queryNewList(@Param("params") Map<String, String> params);

    /**
     * 查询所有正常的服务公司的银行卡号
     * @return
     */
    @Select("SELECT bank_card FROM caishui_service_company WHERE `status` = 1")
    public List<String> queryCompanyBankCard();

    /**
     * 通过账号和记账子单元查询银行商户信息
     * @return
     */
    @Select("SELECT * FROM caishui_business_bank WHERE type = 1 AND main_account = #{mainAccount} AND sub_account_id = #{subAccountId}")
    public CaishuiBusinessBank queryBusinessBank(@Param("mainAccount") String mainAccount, @Param("subAccountId") String subAccountId);

    /**
     * 分组查询充值记录的付款信息(下拉列表)
     * @param params
     * @return
     */
    @Select("SELECT s.payment_account AS value,s.payment_account_name AS label FROM caishui_recharge s WHERE s.`status` = 1 AND s.check_status = 1 " +
            "AND s.company_id = #{params.companyId} AND s.business_id = #{params.businessId} GROUP BY s.payment_account")
    public List<Map<String,Object>> queryRechargePayInfo(@Param("params") Map<String, String> params);

}
